package sicau.car.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import sicau.car.entity.Admin;
import sicau.car.mapper.AdminMapper;
import sicau.car.service.AdminService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import sicau.car.utill.MD5Util;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author ITcz
 * @since 2020-07-28
 */
@Service
public class AdminServiceImpl extends ServiceImpl<AdminMapper, Admin> implements AdminService {
    /*
     * AdminServiceImpl extends ServiceImpl<AdminMapper, Admin>
     *   1.ServiceImpl完成了Mapper对象的注入
     *   2.ServiceImpl提供了常用的CRUD
     * */

    @Autowired
    AdminMapper adminMapper;

    @Override
    public Admin login(String account, String password) {
        String dbPass = MD5Util.inputPassToDbPass(password);
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq("admin",account);
        queryWrapper.eq("password",dbPass);
        Admin admin = adminMapper.selectOne(queryWrapper);
        return admin;
    }

}
